<div id="addTimeTracker">

	<g:flashMessage/>
	<g:hasErrors bean="${timeTrackerInstance}">
		<ul class="errors" role="alert">
			<g:eachError bean="${timeTrackerInstance}" var="error">
				<li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message error="${error}" /></li>
			</g:eachError>
		</ul>
	</g:hasErrors>
	<g:formRemote name="addTimeTracker" url="[ controller:'timeTracker',action:'addTimeTrackerEvent']"  update="addTimeTracker"  id="frmAddTimeTracker" class="columns">
			<g:hiddenField name="issue.id" value="${issueId }"/>
			<g:hiddenField name="project.id" value="${projectId }"/>
			<g:hiddenField name="developmentTask.id" value="${developmentTaskId }"/>
			<g:hiddenField name="developmentTaskChecklist.id" value="${developmentTaskChecklistId }"/>
			<g:hiddenField name="deployment.id" value="${deploymentId }"/>
			<g:hiddenField name="person.id" value="${session.currentUserId }"/>
			<table class="searchable tableForm boxSilver">
				<tr>
					<td class="fieldcontain ${hasErrors(bean: timeTrackerInstance, field: 'dateOfWork', 'error')} required"><label for="dateOfWork"><g:message code="timeTracker.dateOfWork.label" default="Date Of Work" /> <span class="required-indicator">*</span></label></td>
					<td class="fieldcontain ${hasErrors(bean: timeTrackerInstance, field: 'dateOfWork', 'error')} required"><g:jqDatePicker  name="dateOfWork" value="${timeTrackerInstance?.dateOfWork == null ? new Date() : timeTrackerInstance?.dateOfWork}" width="20"/></td>
					<td class="fieldcontain ${hasErrors(bean: timeTrackerInstance, field: 'phase', 'error')} required"><label for="phase"><g:message code="timeTracker.phase.label" default="Phase" /> <span class="required-indicator">*</span></label></td>
					<td class="fieldcontain ${hasErrors(bean: timeTrackerInstance, field: 'phase', 'error')} required"><g:select id="phase" name="phase.id" from="${edu.uow.devdocs.Phase.list()}" optionKey="id" required="" value="${timeTrackerInstance?.phase?.id}" class="many-to-one"/></td>
				</tr>
				<tr>
					<td class="fieldcontain ${hasErrors(bean: timeTrackerInstance, field: 'hours', 'error')} required"><label for="hours"><g:message code="timeTracker.hours.label" default="Hours" /> <span class="required-indicator">*</span></label></td>
					<td class="fieldcontain ${hasErrors(bean: timeTrackerInstance, field: 'hours', 'error')} required"><g:textField type="number" name="hours" required="" value="${fieldValue(bean: timeTrackerInstance, field: 'hours')}" /></td>
					<g:if test="${developmentTaskId }">
					<td class="fieldcontain ${hasErrors(bean: timeTrackerInstance, field: 'developmentChecklist', 'error')}"><label for="phase"><g:message code="timeTracker.developmentChecklist.label" default="Development Checklist" /></label></td>
					<td class="fieldcontain ${hasErrors(bean: timeTrackerInstance, field: 'developmentChecklist', 'error')}"><g:select noSelection="['':'']" id="developmentChecklist" name="developmentChecklist.id" from="${edu.uow.devdocs.DevelopmentTask.get(developmentTaskId)?.developmentChecklists}" optionKey="id" value="${timeTrackerInstance?.developmentChecklist?.id}" class="many-to-one"/></td>
					</g:if>
				</tr>
				<tr>
					<td class="fieldcontain ${hasErrors(bean: timeTrackerInstance, field: 'comments', 'error')}"><label for="comments"><g:message code="timeTracker.comments.label" default="Comments" /></label></td>
					<td colspan="3" class="fieldcontain ${hasErrors(bean: timeTrackerInstance, field: 'comments', 'error')}"><g:textArea class="large" name="comments" maxlength="2000" value="${timeTrackerInstance?.comments}" /></td>
				</tr>
			</table>
		<fieldset class="form-actions">
			<g:submitButton class="save" name="addTimeTracker" value="Add" controller="timeTracker" action="addTimeTrackerEvent" update="addTimeTracker"/>
		</fieldset>
		
		</g:formRemote>
		<g:if test="${issueId}">
			<g:set var="timeTrackerList" value="${edu.uow.devdocs.TimeTracker.findAllByIssue(edu.uow.devdocs.Issue.get(issueId)) }"></g:set>
		</g:if>
		<g:if test="${developmentTaskId}">
			<g:set var="timeTrackerList" value="${edu.uow.devdocs.TimeTracker.findAllByDevelopmentTask(edu.uow.devdocs.DevelopmentTask.get(developmentTaskId)) }"></g:set>
		</g:if>
		<g:if test="${deploymentId}">
			<g:set var="timeTrackerList" value="${edu.uow.devdocs.TimeTracker.findAllByDeployment(edu.uow.devdocs.Deployment.get(deploymentId)) }"></g:set>
		</g:if>
				<table class="sortable">
					<thead>
						<tr>
							<th><g:message code="timeTracker.dateOfWork.label" default="Date Of Work" /></th>
							<th><g:message code="timeTracker.hours.label" default="Hours" /></th>
							<th><g:message code="timeTracker.comments.label" default="Comments" /></th>
							<th><g:message code="timeTracker.taskId.label" default="Task Id" /></th>
							<th><g:message code="timeTracker.project.label" default="Project" /></th>
							<th><g:message code="timeTracker.phase.label" default="Phase" /></th>
							<th><g:message code="timeTracker.person.label" default="Person" /></th>
							<th><g:message code="timeTracker.downtimeReport.label" default="Downtime Report" /></th>
							<th><g:message code="timeTracker.issue.label" default="Issue" /></th>
							<th><g:message code="timeTracker.developmentTask.label" default="Development Task" /></th>
							<th><g:message code="timeTracker.developmentChecklist.label" default="Development Checklist" /></th>
							<th><g:message code="timeTracker.deployment.label" default="Deployment" /></th>
						</tr>
					</thead>
					<g:each in="${timeTrackerList}" status="i" var="timeTrackerItemInList">
						<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
							<td><g:link controller="timeTracker" action="show" id="${timeTrackerItemInList.id}"><g:formatDate format="dd/MM/yyyy" date="${timeTrackerItemInList.dateOfWork}"/></g:link></td>
							<td>${fieldValue(bean: timeTrackerItemInList, field: "hours")}</td>
							<td>${fieldValue(bean: timeTrackerItemInList, field: "comments")}</td>
							<td>${fieldValue(bean: timeTrackerItemInList, field: "taskId")}</td>
							<td>${fieldValue(bean: timeTrackerItemInList, field: "project")}</td>
							<td>${fieldValue(bean: timeTrackerItemInList, field: "phase")}</td>
							<td>${fieldValue(bean: timeTrackerItemInList, field: "person")}</td>
							<td>${fieldValue(bean: timeTrackerItemInList, field: "downtimeReport")}</td>
							<td>${fieldValue(bean: timeTrackerItemInList, field: "issue")}</td>
							<td>${fieldValue(bean: timeTrackerItemInList, field: "developmentTask")}</td>
							<td>${fieldValue(bean: timeTrackerItemInList, field: "developmentChecklist")}</td>
							<td>${fieldValue(bean: timeTrackerItemInList, field: "deployment")}</td>
						</tr>
					</g:each>
					</table>
</div>